This repository contains all the necessary reproducibility materials for "A New Measure of Affective Polarization" by Nicolas Campos and Christopher Federico.

Within this repo is an R project file, raw and cleaned data for each of the four studies, R script for cleaning the raw data, R script for producing the results in the main text and appendices of the article, and R script for producing all plots.

To run the code, first open the R project file, as all data and plots are saved using the project as the reference directory. Next, R script within each study folder (e.g. Study 1, Study 2) can be run to clean the raw data, look at study demographics, as well as individual scale metrics. If you are only interested in the main results, the "Main Analyses" folder contains two separate scripts: "Scale Construction.R" where any psychometric analyses for the APS are located, and "Scale Validation.R" where the regression analyses and plots can be found. Additionally, there is a third R script in the Main Analyses folder labelled "PureIndepedents.R" that contains the exploratory psychometrics for the APS among pure independents, which is reported in the appendix.

This repo should work the same for Windows and Mac computers, as all file paths are defined based on the R project. Each R script contains the necessary packages in the preamble.

The parallel analyses are reliant on Monte-Carlo simulations of eigenvalues, and therefore a seed has been set at the top of the "Scale Construction.R" script.

To find all the item wordings and response values, a PDF is located in the "Survey Materials" folder which lists every item given to respondents for each of the four studies.

File Structure is below, in parentheses are additional file descriptions to help people naviagte the files.

Main Analyses
- dataS1.RData
- dataS1_Codebook.docx
- dataS2.RData
- dataS2_Codebook.docx
- dataS3.RData
- dataS3_Codebook.docx
- dataS4.RData
- dataS4_Codebook.docx
- dataS4TS.RData
- dataS4TS_Codebook.docx
- IndDatS4W3.RData
- IndDatS4W3_Codebook.docx
- PureIndependents.R (exploratory code for APS among independents)
- Scale Contruction.R
- Scale Validation.R

Plots
- aPatch.pdf (item and test information curves for aversion)
- Figure1.pdf
- Figure2.pdf
- Figure3.pdf
- Figure4.pdf
- mPatch.pdf (item and test information curves for moralization)
- oPatch.pdf (item and test information curves for othering)
  
Study 1 - Prolific
- Cleaning_S1.R
- Demo_Dem_S1.csv (demographics for democrat sample)
- Demo_Rep_S1.csv (demographics for republican sample)
- Qual_S1.csv (raw qualtrics survey output)
- Qual_S1_Codebook.docx
  
Study 2 - Prolific
- Cleaning_S2.R
- Demo_Dem_S2.csv (demographics for democrat sample)
- Demo_Rep_S2.csv demographics for republican sample)
- Qual_S2.csv (raw qualtrics survey output)
- Qual_S2_Codebook.docx
  
Study 3 - Lucid
- Cleaning_S3.R
- Lucid Codebook.csv (codebook for Lucid's demographic variables)
- Qual_S3.csv (raw qualtrics survey output)
- Qual_S3_Codebook.docx
  
Study 4 - Bovitz
- Bovitz Codebook.xlsx (codebook for Bovitz's demographic variables)
- TS (folder containing files needed to produce panel dataset, Ts corrspond to waves)
  - Cleaning_S4TS.R
  - dataT1.RData
  - dataT1_Codebook.docx
  - dataT2.RData
  - dataT2_Codebook.docx
  - dataT3.RData
  - dataT3_Codebook.docx
- Wave 1
  - Bovitz_Demo_S4W1.csv (demographic variables)
  - Bovitz_QualS4W1.csv (raw qualtrics survey output)
  - Bovitz_QualS4W1_Codebook.docx
  - Cleaning_S4W1.R
- Wave 2
  - Bovitz_QualS4W2.csv (raw qualtrics survey output)
  - Bovitz_QualS4W2_Codebook.docx
  - Cleaning_S4W2.R
  - demoexport.RData (W1 demographics to link to W2 responses)
- Wave 3
  - Bovitz_QualS4W3.csv (raw qualtrics survey output)
  - Bovitz_QualS4W3_Codebook.docx
  - Cleaning_S4W3.R
  - demoexport.RData (W1 demographics to link to W3 responses)
  - IndCleaning.R (code to create pure independents dataset)
    
Survey Materials
- ALL ITEM WORDINGS.pdf






